package model.operator;

import java.sql.SQLException;
import java.util.HashMap;

import com.ibatis.sqlmap.client.SqlMapClient;

public class OperatorDao {
	private SqlMapClient sqlMapClient;
	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}
	//지시사항 DB에 넣기!! - 1단계 - workOrder table 에 insert
	public void workOrderInsert(HashMap map) throws SQLException{
		//System.out.println("다오에서...workOrderInsert"+map);
		sqlMapClient.insert("operator.workOrderInsert",map);
	}
	public void workOrderUpdate(HashMap map) throws SQLException{
			sqlMapClient.update("operator.workOrderUpdate", map);
	}
	//지시사항 DB에 넣기!! - 2단계 - workOrder table 에서 지시번호 받아오기
	public int workOrderMaxNumber() throws SQLException{
		return (Integer) sqlMapClient.queryForObject("operator.workOrderMaxNumber");
	}
	//지시사항 DB에 넣기!! - 3단계 - history table 에 insert //끝//
	public void historyOrderInsert(HashMap map) throws SQLException{
		sqlMapClient.insert("operator.historyOrderInsert",map);
	}
	//지시사항 DB에 넣기!! - 4단계 - history table 에 insert //끝//
		public void historyOrderUpdate(HashMap map) throws SQLException{
			sqlMapClient.update("operator.historyOrderUpdate",map);
		}
	//오늘을 기준으로 몇월인지 알아오기
	public String fetchingMonth() throws SQLException {
		return (String) sqlMapClient.queryForObject("operator.fetchingMonth");
	}
	//오늘을 기준으로 몇일인지 알아오기
	public String fetchingDays() throws SQLException {
		return (String) sqlMapClient.queryForObject("operator.fetchingDays");
	}
	//월일로 목표수량 받아오기
	public String workorderStatistics(HashMap pa_map) throws SQLException {
		String result = (String) sqlMapClient.queryForObject("operator.workorderStatistics",pa_map);
			if(result==null)
				result="0";
		return result;
	}
	//월일로 불량목표 받아오기
	public String workorderbadStatistics(HashMap pa_map) throws SQLException {
		String result = (String) sqlMapClient.queryForObject("operator.workorderbadStatistics",pa_map);
			if(result==null)
				result="0";
		return result;
	}
	//월일로 성공수량 받아오기
	public String historyStatistics(HashMap pa_map) throws SQLException {
		String result = (String) sqlMapClient.queryForObject("operator.historyStatistics",pa_map);
		if(result==null)
			result="0";
		return result;
	}
	
}
